import Vue from 'vue'
import VueRouter from 'vue-router'
import Home_page from '../views/Home_page.vue'
import user from '@/views/sys/user.vue'
import dictionary from '@/views/sys/dictionary.vue'
import login from '@/views/login'
import model from '@/views/activiti/model.vue'
import formFlowEntry from '@/views/activiti/formFlowEntry.vue'

Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    redirect:'/login'
  },
  {
    path: '/login',
    name: 'login',
    component: login,
    meta: { title: '瓜瓜小说' }
  },{
    path: '/Home_page',
    component: Home_page,
    children:[
      {
        path: '/user',
        component: user
      },
      {
        path: '/dict',
        component: dictionary
      },
      {
        path: '/model',
        component: model
      },
      {
        path: '/formFlowEntry',
        component: formFlowEntry
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

//挂载路由导航守卫
router.beforeEach((to,from,next)=>{
  if(to.path=='/login') return next();
  // const tokenStr = window.sessionStorage.getItem('token');
  // if(!tokenStr) return next('/login');
  next();
})
export default router
